<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.model.Building" %>  
<%@ page import="com.control.BuildingControl" %>  
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.model.Student" %>
<%@ page import="com.control.StudentControl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>change</title>
		<script language="javascript"> 
		var searchDefault="如：1990-01-01";   
	    var focusFlag = false;   
	    function inputFocus(e){   
	        if(e.value== searchDefault) {   
	            e.value='';   
	        }   
	        focusFlag = true;   
	        e.style.color="black";   
	    }   
	function inputBlur(e){   
	        if(e.value=='') {   
	            e.value=searchDefault;   
	    e.style.color="#767676";   
	        }   
	    }   
		function check1()
		{
			    if(document.form1.number.value=="")
				{
					alert("账号不能为空");
					document.form1.name.focus();
					return;
				}
				else if(document.form1.name.value=="")
				{
					alert("姓名不能为空");
					document.form1.number.focus();
					return;
				}
				else if(document.form1.password.value=="")
				{
					alert("密码不能为空");
					document.form1.password.focus();
					return;
				}
				else
				{form1.submit();}
		}
</script>
	</head>
	<body>
	<%
		request.setCharacterEncoding("UTF-8");
		int stu_id = Integer.parseInt(request.getParameter("id"));
		Student stu = new Student();
		StudentControl sc = new StudentControl();
		stu = sc.getStudent(stu_id);
	 %>
		<fieldset class="filedset">
			<legend>
				修改学生信息
			</legend>
			<form action="studentInfo_change_deal.jsp?id=<%=stu_id %>" name="form1" method="post"
				style="margin-top: 20px; margin-left: 400px;">
				<span style="color: #376ba5; margin-top: 10px;">学&nbsp;&nbsp;号：</span>
				<input name="number" type="text" id="number" value=<%=stu.getStu_num() %>
					style="margin-top: 10px;">*
				<br />
				<span style="color: #376ba5; margin-top: 10px;">密&nbsp;&nbsp;码：</span>
				<input name="password" type="text" id="password" value=<%=stu.getStu_pwd() %>
					 style="margin-top: 10px;">*
				<br />
				<span style="color: #376ba5; margin-top: 10px;">姓&nbsp;&nbsp;名：</span>
				<input name="name" type="text" id="name"  value=<%=stu.getStu_name() %>
					style="margin-top: 10px;">*
				<br />
				<span style="color: #376ba5; margin-top: 10px;">性&nbsp;&nbsp;别：</span> 
				<select name="sex" id="sex" style="margin-top:10px">
				<option value="男" <%if(stu.getStu_sex().equals("男")) {%> selected="selected" <%} %>>男</option>
				<option value="女" <%if(stu.getStu_sex().equals("女")) {%> selected="selected" <%} %>>女</option>
				</select>	
				<br />
				<span style="color: #376ba5; margin-top: 10px;">生&nbsp;&nbsp;日：</span>
				<input name="birth" type="text" id="birth"  onfocus="inputFocus(this)" onblur="inputBlur(this)" value=<%=stu.getStu_birth() %>
					style="margin-top: 10px;">
				<br />
				<span style="color: #376ba5; margin-top: 10px;">手机号：</span>
				<input name="tel" type="text" id="tel" value=<%=stu.getStu_tel() %>
					style="margin-top: 10px;">*
				<br />
				<span style="color: #376ba5; margin-top: 10px;">寝室长：</span>
				 	<input type = "radio" style="margin-top: 10px;" value = true  name = "leader" />是
   				 	<input type = "radio" style="margin-top: 10px;" value = false  name = "leader"  checked="checked"/>否
   				<br />
				<span style="color: #376ba5; margin-top: 10px;">学&nbsp;&nbsp;院：</span>
				<input name="college" type="text" id="college" value=<%=stu.getStu_college() %>
					 style="margin-top: 10px;">*
				<br />
				<span style="color: #376ba5; margin-top: 10px;">专&nbsp;&nbsp;业：</span>
				<input name="major" type="text" id="major" value=<%=stu.getStu_major() %>
					 style="margin-top: 10px;">*
				<br />
				<span style="color: #376ba5; margin-top: 10px;">寝&nbsp;&nbsp;室：</span>
				<select name="building" size="1"  style="margin-top: 10px;">
										<%
											BuildingControl control = new BuildingControl();
											ArrayList<Building> list = new ArrayList<Building>();
											list = control.getBuildingList(); 
											for(int i=0; i<list.size(); i++) {
												Building building = list.get(i);
										%>
										<option value="<%= building.getBuilding_id() %>" <%if(stu.getStu_building_id() == building.getBuilding_id()%><%){%> selected="selected"<%}%>><%=building.getBuilding_name() %></option>
										<%}%>
										</select>
				<input name="dorm" type="text" id="dorm" size="9" value=<%=stu.getStu_dorm_name() %>
					 style="margin-top: 10px;">*
				<br />
				<input type="submit" value="确定" onclick="check1()"
					style="background: url(../../images/button.gif) no-repeat; margin-left: 40px; border: 0px; height: 28px; width: 62px; margin-top: 20px;" />
				<input name="input" type="reset" value="重置"
					style="background: url(../../images/button.gif) no-repeat; margin-left: 20px; border: 0px; height: 28px; width: 62px; margin-top: 20px;" />
			</form>
		</fieldset>
	</body>
</html>